<template>
    <el-button v-on="$attrs" :size="itemData.size" :style="itemData.style" :type="itemData.type" @click="btnClick">
        {{ itemData.title }}
    </el-button>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import { yzButtonAttribute } from '../../class/ui/yzButtonAttribute'
import { glEvent } from "../../events/glEvent";

export default defineComponent({
    props: {
        itemData: {
            type: yzButtonAttribute,
            required: true
        }
    },
    methods: {
        btnClick() {
            this.$confirm("是否执行", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            }).then(() => {
                console.log("开始请求订阅事件,itemData.name为:", this.itemData.name);
                this.itemData.name && glEvent.ui.emitEvent(this.itemData.name, this.itemData);
            }).catch(()=>{
                console.log("取消请求订阅事件");
            })
        }
    },
    mounted() { }
})
</script>
